package com.wyj.controller;

import com.wyj.pojo.YlrcMenu;
import com.wyj.service.impl.YlrcMenuServiceImpl;
import com.wyj.service.impl.YlrcUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author ：wyj
 * @description：TODO
 * @date ：2022/11/18 9:16 下午
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    YlrcMenuServiceImpl ylrcMenuServiceImpl;


    //增加一个菜单
    @PostMapping
    public String addMenu(YlrcMenu ylrcMenu) {
        try {
            int i = ylrcMenuServiceImpl.addMenu(ylrcMenu);
            if (i > 0) return "增加菜单成功";
        } catch (Exception e) {
            new RuntimeException(e);
        }
        return "增加菜单失败";
    }

    //删除一个菜单
    @DeleteMapping("/{id}")
    public String deleteMenu(@PathVariable("id") int id) {
        try {
            int i = ylrcMenuServiceImpl.deleteMenu(id);
            if (i > 0) return "删除菜单成功";
        } catch (Exception e) {
            new RuntimeException(e);
        }
        return "删除菜单失败";
    }


}
